<template>
  <div>
    <a-space>
      <!-- <a-button @click="initPmpDataByHardCode"> 
        重新读取字典（硬编码）
      </a-button>

      <a-button @click="initPmpDataByJsonFile">
        重新读取字典(Json文件)
      </a-button> -->

      <a-button @click="initPmpDataByDb">
        重新读取字典(从DB)
      </a-button>
      <!-- <a-button @click="clearPmpDataCache"> 清空前端字典缓存 </a-button> -->
      <a-button @click="writePmpDataToJsonFile"> 备份字典 </a-button>

      <CreateSub ></CreateSub>

    </a-space>

<br/>
    发现的一个github,pmp学习相关，https://gitee.com/cheerfullJinyu/pmp<br/>
    项目文档模板：https://gitcode.com/open-source-toolkit/81e0a

  </div>
</template>

<script setup>
import pmpHooks from '@/hooks/PmpHooks.js'
import { messageApi, contextHolder } from '@/utils/MessageUtils.js'
import CreateSub from '@/components/CreateSub.vue'

async function writePmpDataToJsonFile() {
  const r = await pmpHooks.writePmpDataToJsonFile()
  console.log(r)
  messageApi.success("Data has be back up to " + r)
}

async function initPmpDataByHardCode() {
  const r = await pmpHooks.initPmpDataByHardCode()
  await pmpHooks.initPmpDict()
  messageApi.success(r)
}

async function initPmpDataByJsonFile() {
  const r = await pmpHooks.initPmpDataByJsonFile()
  await pmpHooks.initPmpDict()
  messageApi.success(r)
}

async function initPmpDataByDb(){
  const r = await pmpHooks.initPmpDataByDb()
  await pmpHooks.initPmpDict()
  messageApi.success(r)
}

function clearPmpDataCache() {
  pmpHooks.clearPmpDataCache()
  messageApi.success('SUCCESS')
}


</script>

<style></style>
